
// UstavMFCServerDlg.h : header file
//

#pragma once
#include "afxwin.h"

#include "SerialPort.h"

#include "UR_GOTO.h"
#include "UR_LIGHTS.h"
#include "US_DATA.h"
#include "US_STATUS.h"

// CUstavMFCServerDlg dialog
class CUstavMFCServerDlg : public CDialogEx
{
// Construction
public:
	CUstavMFCServerDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_USTAVMFCSERVER_DIALOG };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
    
// Implementation
protected:
	HICON m_hIcon;

    CSerialPort m_serialPort;
    USData m_UsData;
    USStatus m_UsStatus;

    CMap<CString, LPCTSTR, CSerialPort::Parity, CSerialPort::Parity> m_parityMap;
    CMap<CString, LPCTSTR, CSerialPort::StopBits, CSerialPort::StopBits> m_stopBitsMap;
    CMap<CString, LPCTSTR, CSerialPort::FlowControl, CSerialPort::FlowControl> m_flowControlMap;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()

    void LogMessage(LPCTSTR pszText);

    void InitPorts();
    void InitBauds();
    void InitParities();
    void InitDataBits();
    void InitStopBits();
    void InitFlowControls();

    void OpenSerialPort();
    void CloseSerialPort();
    
    void EnableLockCheckBoxes(BOOL enable);
    void EnableSendButtons(BOOL enable);

    
public:
    CButton m_checkLock_port;
    CButton m_checkLock_baud;
    CButton m_checkLock_parity;
    CButton m_checkLock_dataBits;
    CButton m_checkLock_stopBits;
    CButton m_checkLock_flowControl;
    CButton m_checkLock_overlapped;
    
    BOOL m_enabled_port;
    BOOL m_enabled_baud;
    BOOL m_enabled_parity;
    BOOL m_enabled_dataBits;
    BOOL m_enabled_stopBits;
    BOOL m_enabled_flowControl;
    BOOL m_enabled_overlapped;
    
    CComboBox m_cb_port;
    CComboBox m_cb_baud;
    CComboBox m_cb_parity;
    CComboBox m_cb_dataBits;
    CComboBox m_cb_stopBits;
    CComboBox m_cb_flowControl;
    CButton m_b_overlapped;

    CEdit m_logBox;
    CButton m_b_openClosePort;
    
    CButton m_b_sendData;
    CButton m_b_sendStatus;

    afx_msg void OnBnClickedCheckLockPort();
    afx_msg void OnBnClickedCheckLockBaud();
    afx_msg void OnBnClickedCheckLockParity();
    afx_msg void OnBnClickedCheckLockDataBits();
    afx_msg void OnBnClickedCheckLockStopBits();
    afx_msg void OnBnClickedCheckLockFlowControl();
    afx_msg void OnBnClickedCheckLockOverlapped();
    afx_msg void OnBnClickedButtonOpenClosePort();
    afx_msg void OnBnClickedButtonSendData();
    afx_msg void OnBnClickedButtonSendStatus();  
    
    int m_yaw;
    int m_pitch;
    int m_roll;
    int m_heading;
    double m_latitude;
    double m_longitude;
    float m_altitude;
    float m_airSpeed;
    float m_groundSpeed;
    int m_consumption;
    int m_batteryLife;
    int m_health;
};
